class HeartBeat {
  ws:any = null
  timeout:any = 1000
  timeoutObj:any = null
  serverTimeoutObj:any = null

  // 这个ws是data里面的wsInstance
  constructor (ws:any) {
    this.ws = ws
  }

  reset () {
    clearTimeout(this.timeoutObj)
    clearTimeout(this.serverTimeoutObj)
    return this
  }

  start () {
    this.timeoutObj = setTimeout(() => {
      this.serverTimeoutObj = setTimeout(() => {
        this.ws.close()
      }, this.timeout)
    }, this.timeout)
  }
}

export default HeartBeat
